<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 20px;
            height: 20px;   
            background-color: #f00;
            border-radius: 50%;
            position: absolute;
        }
    </style>
</head>
<body>

    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>

    <script>

        const oDivs = document.querySelectorAll('div') ;

        document.onmousemove = function(e) {
            // for(let i = 0 ; i < oDivs.length ; i++) {
            //     oDivs[i].style.left = e.x + 'px'
            //     oDivs[i].style.top = e.y + 'px'
            // }

            for(let i = oDivs.length - 1 ; i > 0 ; i--) {
                oDivs[i].style.left = oDivs[i-1].style.left ;
                oDivs[i].style.top = oDivs[i-1].style.top ;
            }

            oDivs[0].style.left = e.x + 'px' ;
            oDivs[0].style.top = e.y + 'px' ;
        }

    </script>
    
</body>
</html>